package com.jd.dict.helper;

import com.jd.dict.config.ConfigClass;
import com.jd.dict.model.TableInfoModel;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TemplateHelper {
	public static void translateIndex() {
        String indexFilePath = ConfigClass.OUT_PATH + "index.html";

        Map<String, String> dataMap = new HashMap<String, String>();
        dataMap.put("systemName", ConfigClass.MODULE_NAME);

        FreemarkerHelper.replaceTemplate(indexFilePath, indexFilePath, dataMap);
	}

    public static void translateHeader() {
        String headerFilePath = ConfigClass.OUT_PATH + "layout" + File.separator + "header.html";

        Map<String, String> dataMap = new HashMap<String, String>();
        dataMap.put("systemName", ConfigClass.MODULE_NAME);

        FreemarkerHelper.replaceTemplate(headerFilePath, headerFilePath, dataMap);
    }

    public static void translateMenu(List<TableInfoModel> tableList) {
        String menuFilePath = ConfigClass.OUT_PATH + "layout" + File.separator + "menu.html";

        Map<String, List<TableInfoModel>> dataMap = new HashMap<String, List<TableInfoModel>>();
        dataMap.put("menus", tableList);

        FreemarkerHelper.replaceTemplate(menuFilePath, menuFilePath, dataMap);
    }
}
